<script setup>
import { RouterLink, RouterView } from 'vue-router'
import NavMenu from './components/NavMenu.vue';
import SearchInput from './components/SearchInput.vue'
import UserInfo from './components/UserInfo.vue';
import { getUserInfo } from './api/userApi';
import { useUserStore } from './stores/user';

const userStore = useUserStore()

getUserInfo().then((res) => {
  console.log(res)
  userStore.setUserInfo(res)
})
</script>

<template>
  <div class="container">
    <!-- 顶部导航栏 -->
    <div class="navbar">
      <div class="navbar-left">
        <div class="logo">
          <RouterLink to="/">TechBlog</RouterLink>
        </div>
        <NavMenu class="nav-menu" />
        <SearchInput />
      </div>
      <div class="navbar-right">
        <UserInfo />
      </div>
    </div>

    <!-- 主体部分 -->
    <div class="main">
      <div class="content">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<style scoped>
.container {
  width: 100%;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0px;
  border-bottom: solid 1px var(--el-menu-border-color);
}

.navbar-left {
  display: flex;
  align-items: center;
}

.nav-menu {
  border-bottom: none;
  margin-left: 24px;
  margin-bottom: 0px;
}

.logo {
  font-size: 18px;
  font-weight: bold;
}

.logo a {
  text-decoration: none;
}

.navbar-right {
  display: flex;
  align-items: center;
}

.main {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
}

.content {
  padding: 24px;
}
</style>
